package com.gzc.just.play.last.war.sceneserver.gameobject.base;

/**
 * 游戏对象类型枚举
 * 
 * 对应C++ EGameObjectType
 * 
 * @author AI Assistant
 * @version 1.0.0
 * @since 2025-11-22
 */
public enum GameObjectType {
    HERO(1, "英雄"),
    SOLDIER(2, "士兵"),
    MONSTER(3, "野怪"),
    NPC(4, "NPC"),
    BUILDING(5, "建筑"),
    EFFECT(6, "效果"),
    ITEM(7, "物品"),
    AREA(8, "区域"),
    UNKNOWN(0, "未知");

    private final int code;      // 类型编码
    private final String name;   // 类型名称

    GameObjectType(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    /**
     * 根据编码获取类型
     */
    public static GameObjectType fromCode(int code) {
        for (GameObjectType type : GameObjectType.values()) {
            if (type.code == code) {
                return type;
            }
        }
        return UNKNOWN;
    }

    /**
     * 根据名称获取类型
     */
    public static GameObjectType fromName(String name) {
        for (GameObjectType type : GameObjectType.values()) {
            if (type.name.equals(name)) {
                return type;
            }
        }
        return UNKNOWN;
    }
}
